<?php

class passportController extends RPHP_Controller
{

    public function v()
    {
        echo 1111;die;


    }
    //登录
    public function signin()
    {
        $m = $this->model;

        $wechat = $m->checkWechat();

        if ($wechat) {
            // 微信登录
            if ($_GET['url'] != "") {
                
                $_SESSION['HTTP_REFERER'] = $_GET['url'];
            }

            $this->redirect("/wechat/oauth");

        } else {
            $this->display();
        }

    }

    // AJAX
    public function ajax()
    {
        $data['code'] = 900;

        $m = $this->model;

        
        if ($_POST['act'] == 'signin') {

            $data = $m->doSignin($_POST);

        }else if($_POST['act'] == 'login'){
            // 登录
            $data = $m->doLogin($_POST);
            
        }else if($_POST['act'] == 'reg'){
            // 注册
           
            $data = $m->doReg($_POST);
            
        }

        echo json_encode($data);
    }
    
    //z注册页面
   public function register()
   {
       $this->display();
       
   }
    
    //退出登录
    public function signout()
    {
        $m    = $this->model;
        $user = $m->checkAuth(false);
        
        if ($user) {
            $m->doSignout();
        }
    
        $this->redirect("/passport/signin");
    
    }
}
